#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        vector<int> dp(nums.begin(), nums.end());
        for (int i = 1; i < nums.size(); i++)
            dp[i] = max(dp[i], dp[i] + dp[i - 1]);
        int ret = dp[0];
        for (int i = 1; i < nums.size(); i++)
            ret = max(ret, dp[i]);
        return ret;
    }
};